package be.ipl.pigolo.testUcc;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.FileNotFoundException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.junit.Before;
import org.junit.Test;

import be.ipl.pigolo.usecases.GestionPartie;

public class TestJournal {

	private static GestionPartie gp ;
	
	@Before
	public void setUp() throws Exception {
		try {
			Context jndi = new InitialContext();
			gp = (GestionPartie) jndi
					.lookup("ejb:PigoloEAR/PigoloEJB/GestionPartieImpl!be.ipl.pigolo.usecases.GestionPartie");
			assertNotNull(gp);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
	}
	@Test
	public void testJournalPartieVide(){
		assertEquals("<ERROR : Nom>",this.gp.journal(""));
	}
	
	@Test
	public void testJournalPartieNonCommence(){
		this.gp.creerPartie("partie10", 5);
		assertEquals("Fichier log inexistant pour le moment",this.gp.journal("partie10"));
	}
	
	@Test
	public void testJournalPartieCommence(){
		this.gp.creerPartie("partie11", 5);
		this.gp.commencerPartie("partie11");
		assertNotNull(this.gp.journal("partie11"));
	}
}
